package com.samebuilding.service.impl;

import java.util.List;

import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.springframework.transaction.annotation.Transactional;

import com.samebuilding.dao.PhotoCategoryDAO;
import com.samebuilding.domain.PhotoCategory;
import com.samebuilding.service.PhotoCategoryService;
import com.samebuilding.util.WebUtil;

public class PhotoCategoryServiceImpl implements PhotoCategoryService {
	PhotoCategoryDAO photoCategoryDAO;



	public PhotoCategoryDAO getPhotoCategoryDAO() {
		return photoCategoryDAO;
	}

	public void setPhotoCategoryDAO(PhotoCategoryDAO photoCategoryDAO) {
		this.photoCategoryDAO = photoCategoryDAO;
	}

	@Transactional
	public void saveOrUpdatePhotoCategory(PhotoCategory category) {
		WebContext ctx = WebContextFactory.get();
		category.setUserNo(WebUtil.getUserNo(ctx.getHttpServletRequest()));
		photoCategoryDAO.saveOrUpdate(category);

	}

	@Transactional
	public void deletePhotoCategory(int id) {
		photoCategoryDAO.delete(id);

	}
	
	public List<PhotoCategory> getAllPhotoCategory() {
		return photoCategoryDAO.findAll();
	}

	public List<PhotoCategory> getAllPhotoCategoryByUserNo() {
		WebContext ctx = WebContextFactory.get();
		int userNo=WebUtil.getUserNo(ctx.getHttpServletRequest());
		return photoCategoryDAO.findPhotoCategoryByUserNo(userNo);
	}



}
